import { createStore } from 'vuex'

const store = createStore({
    state: {
        loginUser: null,
        curDir: null
    },
    mutations: {
        setLoginUser(state, user) {
            state.loginUser = user
        },
        setCurDir(state, dir) {
            state.curDir = dir
        }
    },
    getters: {
        getLoginUser(state) {
            return state.loginUser == null ? JSON.parse(sessionStorage.getItem('loginUser')) : state.loginUser
        },
        getCurDir(state) {
            return state.curDir == null ? JSON.parse(sessionStorage.getItem('curDir')) : state.curDir
        }
    }
})

export default store